package com.pattern.observer.service.impl;

import com.pattern.observer.service.Observer;

public class Student implements Observer {
    private String name;
    private String phone;
    private Teacher teacher;

    public Student(String name, Teacher teacher){
        this.name = name;
        this.teacher = teacher;
    }

    public void show(){
        System.out.println("Name:"+name+"\nTeacher'sphone:"+phone);
    }

    @Override
    public void update() {
        this.phone = this.teacher.getPhone();
    }
}
